<%= form_tag(
      orders_path,
      method: :get,
      role: 'form',
      class: 'form-inline') do %>
  <%= text_field_tag :keyword, @keyword, class: 'form-control' %>
  <%= render partial: "admin/order/datetime_picker", locals: { name: :from, val: @from } %>
  <%= render partial: "admin/order/datetime_picker", locals: { name: :to, val: @to } %>
  <%= render partial: "admin/order/timezone" %>
  <%= submit_tag t("admin.search"), class: 'btn btn-primary' %>
  <%= submit_tag(
        t("admin.clear"),
        class: 'btn btn-danger',
        onclick: "location.href='#{orders_path}';return false;") %>
<% end %>
<p><%= t "admin.order_search_hint" %></p>

<br/>

<%= paginate @orders %>

<table class="table table-hover table-bordered table-striped table-condensed clickable_table">
  <tr>
    <th><%= t "admin.code" %></th>
    <th><%= t "admin.user_info" %></th>
    <th><%= t "admin.desc" %></th>
    <th><%= t "admin.total" %></th>
    <th><%= t "admin.payment_method" %></th>
    <th><%= t "admin.status" %></th>
    <th><%= t "admin.last_update" %></th>
  </tr>
  <% @orders.each do |o| %>
    <tr onclick="location.href='<%= edit_order_path(o) %>';">
      <td><%= o.code %></td>
      <td>
        <% if o.user %>
          <div><%= render partial: "admin/user_fb", locals: {user: o.user} %></div>
        <% end %>
        <% if o.name %>
          <div><%= o.name %></div>
        <% end %>
        <% if o.email %>
          <div><%= o.email %></div>
        <% end %>
        <% if o.address %>
          <div><%= o.address %></div>
        <% end %>
        <% if o.phone %>
          <div><%= o.phone %></div>
        <% end %>
      </td>
      <td><%= o.desc %></td>
      <td><%= number_to_currency o.sum, unit: "", precision: 0 %></td>
      <td><%= o.payment_as_text %></td>
      <td><%= o.step_as_text %></td>

      <% updated_at_id = "updated_at_#{o.id}" %>
      <td>
        <%= render partial: "common/datetime", locals: { val: o.updated_at } %>
      </td>
    </tr>
  <% end %>
</table>

<%= paginate @orders %>